﻿<local:ControlBase
    xmlns:local="clr-namespace:Rio.Framework.Pages"
    xmlns:controls="clr-namespace:Rio.Framework.Pages.Controls"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    xmlns:converter="clr-namespace:Rio.Framework.Pages.AppCode.Helpers.Converter"
    xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="Rio.Framework.Pages.Controls.VersionInformations"
    mc:Ignorable="d"
    x:Name="controlBase"
    d:DesignHeight="300" d:DesignWidth="400">

    <local:ControlBase.Resources>

        <converter:VersionItemToStyleConverter x:Key="VersionItemToStyleConverter" />

        <DataTemplate x:Key="VersionItemsDataTemplate">
            <Grid>
                <TextBlock Foreground="#FF004C8D" 
                           Margin="{Binding Minor, ConverterParameter=Margin, Converter={StaticResource VersionItemToStyleConverter}}" 
                           FontStyle="{Binding IsCurrentVersion, ConverterParameter=Italic, Converter={StaticResource VersionItemToStyleConverter}}"
                           Text="{Binding FullVersion, StringFormat=- Version \{0\}}"></TextBlock>
                <!--<HyperlinkButton Content="{Binding FullVersion, StringFormat=- Version \{0\}}"
                                 Margin="{Binding Minor, ConverterParameter=Margin, Converter={StaticResource VersionItemToStyleConverter}}"
                                 Command="{Binding ViewSpecificVersionCommand, ElementName=controlBase}"
                                 CommandParameter="{Binding}"
                                 Foreground="#FF004C8D"
                                 FontWeight="{Binding IsCurrentVersion, ConverterParameter=Bold, Converter={StaticResource VersionItemToStyleConverter}}" 
                                 FontStyle="{Binding IsCurrentVersion, ConverterParameter=Italic, Converter={StaticResource VersionItemToStyleConverter}}" />-->
            </Grid>
        </DataTemplate>

    </local:ControlBase.Resources>

    <Grid x:Name="LayoutRoot">
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="VisualStateGroup">
                <VisualState x:Name="NoData">
    				<Storyboard>
    					<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.IsEnabled)" Storyboard.TargetName="radToolBar">
    						<DiscreteObjectKeyFrame KeyTime="0">
    							<DiscreteObjectKeyFrame.Value>
    								<System:Boolean>False</System:Boolean>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    					<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.IsEnabled)" Storyboard.TargetName="listBox">
    						<DiscreteObjectKeyFrame KeyTime="0">
    							<DiscreteObjectKeyFrame.Value>
    								<System:Boolean>False</System:Boolean>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    					<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.IsEnabled)" Storyboard.TargetName="scrollViewer">
    						<DiscreteObjectKeyFrame KeyTime="0">
    							<DiscreteObjectKeyFrame.Value>
    								<System:Boolean>False</System:Boolean>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    				</Storyboard>
    			</VisualState>
                <VisualState x:Name="Default">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.IsEnabled)" Storyboard.TargetName="radToolBar">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Boolean>True</System:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.IsEnabled)" Storyboard.TargetName="listBox">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Boolean>True</System:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.IsEnabled)" Storyboard.TargetName="scrollViewer">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Boolean>True</System:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
    	</VisualStateManager.VisualStateGroups>

        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"  />
            <RowDefinition Height="Auto"  />
            <RowDefinition Height="Auto"  />
            <RowDefinition Height="100"  />
        </Grid.RowDefinitions>

        <TextBlock x:Name="AvalaibleVersions"
                   Grid.Row="0"
                   TextWrapping="Wrap"
                   VerticalAlignment="Center" Text="Versions" Margin="2,0,0,0" HorizontalAlignment="Left" />


        <telerik:RadToolBar x:Name="radToolBar" Grid.Row="1" 
                            Margin="0"
                            GripVisibility="Collapsed"
                            HorizontalAlignment="Stretch"
                            OverflowButtonVisibility="Visible" >
            
            <telerik:RadButton x:Name="buttonAddVersion"
                               Command="{Binding AddVersionCommand, ElementName=controlBase}"
                               CommandParameter="{Binding}">
                <StackPanel Orientation="Horizontal">
                    <Image Width="16"
                           Height="16"
                           Margin="0,0,2,0"
                           Source="/Rio.Framework.Pages;component/Assets/Images/version.png" />
                    <TextBlock x:Name="TextBlockAddVersion"
                               Text="Ajouter"
                               VerticalAlignment="Center" />
                </StackPanel>
            </telerik:RadButton>
            
            <telerik:RadButton x:Name="buttonMakeToMajor"
                               Command="{Binding MakeToMajorCommand, ElementName=controlBase}"
                               CommandParameter="{Binding}"
                               HorizontalAlignment="Stretch">
                <StackPanel Orientation="Horizontal">
                    <Image Width="16"
                           Height="16"
                           Margin="0,0,2,0"
                           Source="/Rio.Framework.Pages;component/Assets/Images/make_major_version.png" />
                    <TextBlock x:Name="TextBlockMakeToMajor"
                               VerticalAlignment="Center" 
                               Text="Convertir en majeure" />
                    
                </StackPanel>
            </telerik:RadButton>
            <!--
            <telerik:RadButton x:Name="CheckoutFile"
                               IsEnabled="False"
                               Command="{Binding CheckOutCommand, ElementName=controlBase}"
                               CommandParameter="{Binding}"
                               HorizontalAlignment="Stretch">
                <StackPanel Orientation="Horizontal">
                    <Image Width="16"
                           Height="16"
                           Margin="0,0,2,0"
                           Source="/Rio.Framework.Pages;component/Assets/Images/make_major_version.png" />
                    <TextBlock x:Name="TextCheckoutFile"
                               VerticalAlignment="Center" 
                               Text="Editer" />

                </StackPanel>
            </telerik:RadButton>-->

        </telerik:RadToolBar>
        <ListBox x:Name="listBox" Grid.Row="2"
                 Height="160"
                 SelectionChanged="listBox_SelectionChanged"
                 ItemTemplate="{StaticResource VersionItemsDataTemplate}" 
                 ItemsSource="{Binding CurrentDocument.AllVersion, ElementName=controlBase, Mode=OneWay}"/>
        
        <TextBlock x:Name="VersionHistoryTextBlock"
                   Grid.Row="3"
                   TextWrapping="Wrap"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top" Text="Historique" Margin="2,5,0,0" />
        <ScrollViewer x:Name="scrollViewer" Background="#EEEEEE"
                      BorderBrush="Black"
                      BorderThickness="1"
                      Grid.Row="4"
                      HorizontalAlignment="Stretch">
            <TextBlock x:Name="VersionHistory"
                       TextWrapping="Wrap"
                       Text="{Binding TextVersionHistory, ElementName=controlBase, Mode=TwoWay}" Height="100" />
        </ScrollViewer>
    </Grid>
</local:ControlBase>
